var audioId=common.getQueryString("audioId");
var $form=$("form");
$form.validate({
    /**
     * ignore：忽略某些元素不验证
     * @type {String}
     * 例如：ignore: ".ignore" ，忽略所有的带ignore class 的标签
     */
    ignore: ".ignore"
});
window.formObject=$form;
var $houseAudio = $("#house-audio");
var $audioPath=$("#audioPath");
var $fileName=$("#fileName");

$.post(window.globalHost + common.audioDetailPath, {id:audioId}).success(function(data) {
    var detailInfo = common.transformData(data);
    common.initInputByName({
        id:detailInfo.id,
        fileName:detailInfo.fileName,
        audioPath:detailInfo.audioPath,
        content:detailInfo.content,
        audioName:detailInfo.audioName,
    });
    var houseAudioGallery=$houseAudio.gallery({
        readOnly:false,
        title:"上传房源音频",
        url:window.audioHost +common.uploadAudioPath,
        paramName:"file",
        fileFolder:detailInfo.contractNo,
        returnPathName:"fileAccessPath",
        maxFiles:1,
        type:'audio',
        filePaths:detailInfo.audioPath.split(","),
        uploadCallback:function () {
            var path=houseAudioGallery.getFilePaths();
            var fileName = houseAudioGallery.getFileNames();
            $audioPath.val(!!path.length?path.join(","):"");
            $fileName.val(!!fileName.length?fileName.join(","):"");
        },
        deleteCallback:function () {
            var path=houseAudioGallery.getFilePaths();
            var fileName = houseAudioGallery.getFileNames();
            $audioPath.val(!!path.length?path.join(","):"");
            $fileName.val(!!fileName.length?fileName.join(","):"");
        }
    });
});
